Tag Archives: programming

8086 sideway scroller ‘n stuff

Today I was working on my own brew ISA card (wirewrapping).
Did some mini modeling stuff.
Sorted some pipetunes.
And played around with my 8086.

Got it on a desk now, and replaced the harddisk with the CF card.
Also got an old SoundBlaster working, so i wanted to see what of my old code could still run.
Apparanty most code was compiled for 386/486 🙁
So i recompiled some stuff.
Below a horizontal scroller example.

Meanwhile i got my new fans in for my NUC (Kodi player, it was making a hell of a noise due to bad ball bearings.

New Roms (eeprom)

Got some new roms in.
These are for my 8088/8086 the 6502 computer and C64 cartridges.

While I seldom had any problem writing to these, now I could not write one!
Erasing didn´t give me an error?!?

henri@zspot:~/projects/wozmon8088/mon8086$ minipro -w mon8086.rom -p AT28C64
Found TL866II+ 04.2.129 (0x281)
Warning: Firmware is newer than expected.
  Expected  04.2.128 (0x280)
  Found     04.2.129 (0x281)
Erasing... 0.02Sec OK
Writing Code...  9.57Sec  OK
Reading Code...  0.12Sec  OK
Verification failed at address 0x0001: File=0xAA, Device=0xFF

Whenever you get this, check the markings of the chip!

Mine are AT28C64b !!!!!!!!!!!

Change your command accordingly.
Another thing to watchout for is write protect, look at the commands

minipro -l | grep 28C64 
Found TL866II+ 04.2.129 (0x281)
Warning: Firmware is newer than expected.
  Expected  04.2.128 (0x280)
  Found     04.2.129 (0x281)
AM28C64A@DIP28
AM28C64A@PLCC32
AM28C64A@SOIC28
AM28C64AE@DIP28
AM28C64AE@PLCC32
AM28C64AE@SOIC28
AM28C64B@DIP28
AM28C64B@PLCC32
AM28C64B@SOIC28
AM28C64BE@DIP28
AM28C64BE@PLCC32
AM28C64BE@SOIC28
AT28C64
AT28C64@PLCC32
AT28C64@SOIC28
AT28C64B
AT28C64B@PLCC32
AT28C64B@SOIC28
AT28C64E
AT28C64E@PLCC32
AT28C64E@SOIC28
AT28C64F
AT28C64F@PLCC32
AT28C64F@SOIC28
CAT28C64A
CAT28C64A@PLCC32
CAT28C64A@SOIC28
CAT28C64B
CAT28C64B@PLCC32
CAT28C64B@SOIC28
XLE28C64A
XLE28C64A@PLCC32
XLE28C64B
XLE28C64B@PLCC32
XLE28C64B@SOIC28
XLS28C64A
XLS28C64A@PLCC32
XLS28C64B
XLS28C64B@PLCC32
XLS28C64B@SOIC28
28C64A
28C64A@PLCC32
28C64A@SOIC28
28C64AF
28C64AF@PLCC32
28C64AF@SOIC28
28C64B
28C64B@PLCC32
28C64B@SOIC28
UPD28C64
UPD28C64@SOIC28
KM28C64A
KM28C64A@PLCC32
M28C64
M28C64@PLCC32
M28C64@SOIC28
M28C64A
M28C64A@PLCC32
M28C64A@SOIC28
M28C64-xxW
M28C64-xxW@PLCC32
M28C64-xxW@SOIC28
M28C64
M28C64@PLCC32
M28C64@SOIC28
M28C64A
M28C64A@PLCC32
M28C64A@SOIC28
M28C64-xxW
M28C64-xxW@PLCC32
M28C64-xxW@SOIC28
X28C64

Compilers (mainly machinecode)

A compiler is a program that converts instructions into a machine-code or lower-level form so that they can be read and executed by a computer.

Below are some machinecode compilers i’ve used.

FOR X86

Masm – Used this in Msdos
Need linker (link), can use macro’s
Most of my old stuff was written using masm

Tasm – Used this in Msdos
Need linker (tlink)
Some of my old stuff was written using Tasm (our boot demo was)

Fasm – Used this to compile for 8086/8088 under linux
Does not need linker, Open Source, Fast!, Written in fasm

Nasm – Used this for some machinecode under linux
Cross platform, can use Macro’s, Open Source

FOR 65xx

Acme – Multi-platform cross assembler for 6502/6510/65816 CPU
Used for my DIY 6502

CC65 – cc65 – complete cross development package for 65(C)02 systems
Used for my DIY 6502

Kickassembler – Java but works okay

Other compilers are for example the Arduino IDE or PlatformIO, which comes with AVR compilers. (Mostly C based)

FOR AMIGA

Seka – assembler

And a really old skool one i’ve used : PL/M-86 Compiler

I’m not sure i’ve used compilers for 8085/680x

Starfield in a bootloader (No OS)

Here is the starfield running from a bootblock loader (No MSDOS)

I threw my back out last week, so I could not move the old 8086 to a better place. I wanted to prepare this machine to boot from floppy disk.

The starfield above boots into VGA mode 13h (320×200 256 colors)

This one also has a Sound Blaster, so I can test music in a boot sector also!

My 8088 (v40) board has VGA also now.
I’m waiting for my ISA-PCMCIA card as replacement for a harddisk/floppy

Creating a new bootloader for old code

UPDATE 20230721 Bootdemo

I found some parts of our (Edk and Me) bootloader demo.

It was compiled using masm or tasm.
Encountering a problem converting the code into a raw bin, to put on a floppy I diverted to another setup to try to get things working.

Using old code (below) and a example from YT, I made the following setup.

Visual studio code, with the x64 assembly plugin.
xxd as hexviewer.
fasm as assembler (This makes things easier, because it is a native Linux x86 compiler. So no need for dosbox anymore.)

I’ve created a Makefile to automate things.

clean:
        rm -f *obj
        rm -f *.bin

exec:
        fasm demo.asm
        fasm boot.asm
        cat boot.bin loadpart.bin > demo.bin 
        qemu-system-x86_64 -boot a -fda demo.bin 

Some of our old demo code:

;-------- snip
Start:
    JMP     SHORT BootHere
    NOP
    DB      "FASH-EDK"
    DW      512
    DB      2
    DW      1
    DB      2
    DW      0070h
    DW      02d0h       ;max. aantal sectoren van volume A
    DB      0Fdh        ;media descriptor
    DW      0002h       ;aantal sectoren per FAT
    DW      0009h       ;aantal sectoren per spoor
    DW      2
    DW      0
BootHere:
    mov     bp,5
tryboot:
    push bp
    mov     bx,4000h
    mov     es,bx
    mov     bx,0
    mov     cx,2        ;vanaf sector 2
    mov     dx,0        ;drive A, kant 0
    mov     ah,02h
    MOV     AL,8
    int     13h         ;sector(en) lezen
    pop     bp
    jnc     bootok
    dec     bp
    jnz     tryboot
bootok:
    mov     bp,5
;---------- snap

New setup using fasm (bootloader) boot.asm

    org 0x7c00                  ;  still not sure about this, have not found this in our demo

    mov bx, 0x1000              ; load sector address 
    mov es, bx                  
    mov bx, 0x0                 

; Sector read function
    mov dh, 0x0                 ; head 0
    mov dl, 0x0                 ; drive 0
    mov ch, 0x0                 ; cylinder 0
    mov cl, 0x02                ; start sector 

readdisk:
    mov ah, 0x02                ; read sec
    mov al, 0x02                ; demo is > 512 so 2 sectors
    int 0x13                    ; call bios

    mov ax, 0x1000
    mov ds, ax                  
    mov es, ax                     
jmpcode:
    jmp 0x1000:0x0              ; far jmp demo

; Expand bin to 512 byte sector
    times 510-($-$$) db 0       
    dw 0xaa55                   ; Sector header (ROM as this at the start)

Graphics demo i wrote a long time ago, converted into fasm loadpart.asm

	mov ah,0
        mov ax, 4f02h   ; Set VESA video mode
        mov bx, 10dh    ; Your video mode number
	int 10h
	mov al,0
drawall:
	mov dx,0
	mov cx,0

drawloop:
	mov ah,0ch
	mov bh,0
	push ax
	int 10h
	pop ax
	inc al
	inc cx
	cmp cx,319
	jc drawloop
	mov cx,0
	inc dx
	cmp dx,199
	jmp drawloop
jmp drawall

; complete sector with zeros
    times 512-($-$$) db 0   

Booting the demo in milli seconds using qemu.
Next to do: Write this to floppy and test on real hardware.

A reset starts the virtual machine and boots from a virtual floppy.
The drawing of the pixels is slow, because I used a int 10h function for every pixel, instead of writing to screen memory directly.

ndisasm – disassemble binary

ndisasm loadpart.bin 
00000000  B400              mov ah,0x0
00000002  B8024F            mov ax,0x4f02
00000005  BB0D01            mov bx,0x10d
00000008  CD10              int 0x10
0000000A  B000              mov al,0x0
0000000C  BA0000            mov dx,0x0
0000000F  B90000            mov cx,0x0
00000012  B40C              mov ah,0xc
00000014  B700              mov bh,0x0
00000016  50                push ax
00000017  CD10              int 0x10
00000019  58                pop ax
0000001A  FEC0              inc al
0000001C  41                inc cx
0000001D  81F93F01          cmp cx,0x13f
00000021  72EF              jc 0x12
00000023  B90000            mov cx,0x0
00000026  42                inc dx
00000027  81FAC700          cmp dx,0xc7
0000002B  EBE5              jmp short 0x12
0000002D  EBDD              jmp short 0xc
0000002F  0000              add [bx+si],al
00000031  0000              add [bx+si],al
00000033  0000              add [bx+si],al
00000035  0000              add [bx+si],al

UPDATE 20230721 Bootdemo update

Got a part working again in PCem.
This is from our bootdemo.
A scroller and sector loader in a bootsector.
Needed some include files
masm, link, exe2com creates a 12- sector sized floppy.
And we’ve got a (little distorted but working) Scroller in boot sector with custom font!

font:   db 64 dup (0)       ;space
        db 0,0,2,2,0,0,0,0  ;!
        db 0,2,2,2,2,0,0,0
        db 0,2,2,2,2,0,0,0
        db 0,2,2,2,2,0,0,0
        db 0,0,2,2,0,0,0,0
        db 0,0,2,2,0,0,0,0
        db 0,0,0,0,0,0,0,0
        db 0,0,2,2,0,0,0,0

Bios Extension boot and bootsector programs.

Followup on

Today two boot projects.
One using a bios extension, so it chip based.
Second is a floppy disk boot program. (Creating a test situation to get our old Boot floppy demo working. ( That one without using an operatingsystem like ms-dos.

Creating a Secondary Bios ROM

NAME mycode
.model small
ORG 0h

.code
	dw 0AA55h ;  Magic header your bios is looking for
	db 16     ; lenght of this rom in 512 bytes == 8k
	jmp short clear ; jmp to program

ORG 20h                 ; start of program
	
clear:  mov cx,10       ; clear, set keyboard led and print 10 # chars
	mov ah,0ah
	mov al,31h
	int 10h
	mov bh,0
	mov cx,1
start:	mov al, 11000000b
        out 80h, al
print:  mov cx,10
	mov ah,0ah
	mov al,"#"
	int 10h
loop1:  nop           ; loop until doomsday
	jmp loop1
	db -68        ; This makes the checksum 0
                      ; steps to take: edit source, make this byte entry 0
                      ; compile using make.bat in dosbox
                      ; check checksum using my python script
                      ; output was 68 hex 0x44
                      ; edit asm file place -68 to make the checksum 0x00 again
                      ; compile and burn to ROM
ORG 2000h             ; create end of rom 0000h-1fffh = 8K
END

make.bat in dosbox

@ECHO OFF
MASM /DARCH_TYPE="T" /DCPU_TYPE="V" 1;
LINK 1;
EXE2COM 1.EXE

Python script here: https://www.henriaanstoot.nl/2023/06/20/bios-hacking/

Write EEprom

minipro -w 1.COM -p AT28C64

Part 2 – Bootsector program !

Allmost the same as above, but booting from a Floppy disk.

Video mode info : https://stanislavs.org/helppc/int_10-0.html

Assembly code

use16              ; 16 bits 
org 0x7c00         ; start address ( change? )

mov ah,0x0         ; ah 0h - video mode 
mov al,0x0         ; al 0h - mode 0 - 40x25 chars
int 10h            ; scree routines 
mov cx,11h         ; 11 chars
mov ah,0ah         ; ah 0ah - print char mode
mov al,'#'         ; choose char as #
int 10h            ; execute 


times 510 - ($-$$) db 0 ; fill rest 512 bytes sector

dw 0xaa55 ; magic bytes 

Python Spotify Genre Cube v2

Spotify version

Next to do: Lasercut a wooden cube with better lettering.

Run the python part on a server

and

First export some API credentials

export SPOTIPY_CLIENT_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
export SPOTIPY_CLIENT_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
export SPOTIPY_REDIRECT_URI="http://localhost:8080/callback"

Code below:

from flask import Flask, request, redirect
from requests_oauthlib import OAuth2Session
from requests.auth import HTTPBasicAuth
import requests
import json
import spotipy
from spotipy.oauth2 import SpotifyOAuth
from pprint import pprint
from time import sleep
import spotipy.util as util
import sys
import paho.mqtt.client as mqttClient
import time
import os
import subprocess

Connected = False


broker_address = "MQTTSERVER"
port = 1883


def on_connect(client, userdata, flags, rc):
    if rc == 0:
        print("Connected to broker")
        global Connected
        Connected =True
    else:
        print("Connection failed")

def on_message(client, userdata, message):
    print (message.payload)
    myurl = 'spotify:playlist:' + str(message.payload.decode())

    results = sp.start_playback(context_uri=myurl, offset={"position": 1})

client = mqttClient.Client("PythonSpotifyGenreCube")
client.on_connect = on_connect
client.on_message = on_message

client.connect(broker_address, port=port,keepalive=60 )
client.loop_start()
time.sleep(4) # Wait for connection setup to complete
client.subscribe('spotify/playlist')
#client.loop_stop()    #Stop loop

#while Connected != True:
#    client.loop()
#    time.sleep(0.1)
#    print("test")
#    client.subscribe('spotify/playlist')



app = Flask(__name__)

AUTH_URL = 'https://accounts.spotify.com/authorize'
TOKEN_URL = 'https://accounts.spotify.com/api/token'
REDIRECT_URI = 'http://localhost:8080/callback'
CLIENT_ID = "xxxxxxxxxxxxxxxxxx"
CLIENT_SECRET = "xxxxxxxxxxxxxxxxxxxxx"
SCOPE = [
    "user-read-email",
    "playlist-read-collaborative"
]

@app.route("/login")
def login():
    spotify = OAuth2Session(CLIENT_ID, scope=SCOPE, redirect_uri=REDIRECT_URI)
    authorization_url, state = spotify.authorization_url(AUTH_URL)
    return redirect(authorization_url)

@app.route("/callback", methods=['GET'])
def callback():
    code = request.args.get('code')
    res = requests.post(TOKEN_URL,
        auth=HTTPBasicAuth(CLIENT_ID, CLIENT_SECRET),
        data={
            'grant_type': 'authorization_code',
            'code': code,
            'redirect_uri': REDIRECT_URI
        })
    return json.dumps(res.json())


username = "fashice"
scope = "user-read-playback-state,user-modify-playback-state,playlist-read-private"
util.prompt_for_user_token(username,scope,client_id='xxxxxxxxxxxxxxxxxxxxx',client_secret='xxxxxxxxxxxxxxxxxxxxxxxxxxxx',redirect_uri='http://localhost:8080/callback')

sp = spotipy.Spotify(client_credentials_manager=SpotifyOAuth(scope=scope))

# Shows playing devices
res = sp.devices()
pprint(res)


# Change track
#sp.start_playback(uris=['spotify:track:6gdLoMygxxxxxxxxxxxxxxx'])
#results = sp.start_playback(context_uri=myurl, offset={"position": 1})


## Change volume
#sp.volume(100)
#sleep(2)
#sp.volume(50)
#sleep(2)
#sp.volume(100)
#


playlists = sp.user_playlists(username)

#for playlist in playlists['items']:
#    print(playlist['name'])


playlists = sp.current_user_playlists()
#print (playlists)
for playlist in playlists['items']:
    print(playlist['id'] + ' ' +  playlist['name'])



#if __name__ == '__main__':
#   app.run(port=8080,debug=True)


while Connected != True:
    time.sleep(0.1)
    client.subscribe('spotify/playlist')

try:
    while True:
        time.sleep(1)


except KeyboardInterrupt:
    print ("exiting")
    client.disconnect()
    client.loop_stop()

Machine code Monitor in ROM on real BBC Acorn Hardware

My BBC Acorn model B is working again. The original monitor is still dead.

Time to play with some machine code and ROMs.

My machine has a NFS rom installed. (NetFS)

Econet was Acorn Computers’s low-cost local area network system, intended for use by schools and small businesses. It was widely used in those areas, and was supported by a large number of different computer and server systems produced both by Acorn and by other companies.

I found a ROM online called Gremlin. It is a 16K rom file. But at the moment I only got some 28C64 (8k) or 28C256 (32k) eeproms.

32k it is. But de beeb having address line A14 floating high, I need to flash the upper 16k of the 32k ROM.

So I made the 16K rom into a 32K using cat

cp Gremlin\ v1.21\ \(1983\)\(Computer\ Concepts\).rom 16k.rom
cat Gremlin\ v1.21\ \(1983\)\(Computer\ Concepts\).rom >> 16k.rom

minipro -w 16k.rom -p AT28C256

I got the rom from this page:
https://acorn.huininga.nl/pub/unsorted/roms/Gremlin%20v1.21%20(1983)(Computer%20Concepts).rom

Below booting straight into the monitor program.

Manual:

6502 and Wozmon

Ben posted a youtube about Wozmon running on his 6502.

In 1976, Steve Wozniac wrote what’s commonly known simply as Wozmon.

Wozmon is a machine-code monitor program written by Wozniak for the Apple 1. In Only 256 bytes ! Being pure 6502 code easily adaptable.
A monitor program allows you to view/edit and run machine code using simple commands.

I’ve got a different setup as Ben’s computer.
But changing the necessary, and it will run on my 6502.

I’m not using rs232 voltage levels (-7 till -25 and +7 till +25 volts).
I’m using a usb serial uart standard 5v leveling stick …

For address decoder see other post

Simplified schematic of my UART/ACIA

Compiling the Wosmon gave me an error, DEC is not a valid opcode for a bare 6502 .. but we have a 65c02.
Solution: Add -c02 extra opcodes

error 1 in line 187 of "wozmon.s": illegal operand types
>                DEC                    ; Decrement A.

# fix .. add -c02
vasm6502_oldstyle -c02 -Fbin -dotdir wozmon.s

Below Apple I Manual with the sourcecode for Wozmon

Debugging a cool robot

A friend bought a mini robot for his son.
But it didn’t work as it should.

No way i let this opportunity pass to play with it!

This is the one:
https://elektronicavoorjou.nl/product/maqueen-plus-v2/
Maqueen Plus V2 – Geavanceerde STEM Educatie Robot voor micro:bit

https://wiki.dfrobot.com/SKU_MBT0021-EN_Maqueen_Plus_STEAM_Programming_Educational_Robot#target_0

So you can program this in a blockly like manner.

Problems we encountered:

  • Uploading didn’t work
    Solution: Using chrome it had access to the usb port to upload, firefox didn’t work
  • The program didn’t compile, faulty or zero size hex file.
    Solution: Wrong Maqueen library was in the examples
    (After changing, needed version update also, see below)
  • Not everything is in Dutch (I like English, but this is for the boy), maqueen V2 needed a lot of translation.
    (So we joined https://crowdin.com/project/makecode/nl to help translating the libraries)

Apparently my AI camera can be connected to this robot!